package com.muli.muwai.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muli.muwai.entity.IntfAreaMessage;
import com.muli.muwai.entity.IntfTarget;
import com.muli.muwai.mapper.TargetMapper;
import com.muli.muwai.service.TargetService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TargetServiceImpl extends ServiceImpl<TargetMapper, IntfTarget> implements TargetService {
    @Override
    public void target(List<String[]> target) {
        List<IntfTarget> list = new ArrayList<>();
        for (String[] strings : target) {
            IntfTarget entity = new IntfTarget();
            entity.setRuleId(strings[0]);
            entity.setTargetRules(strings[1]);
            entity.setFiscalYear(strings[2]);
            entity.setTargetType(strings[3]);
            entity.setAssess(strings[4]);
            entity.setYearly(strings[5]);
            //entity.setJanuary(strings[6]);
            String s0 = strings[6];
            if (s0.equals("")) {
                entity.setJanuary(Double.valueOf(0));
            } else {
                entity.setJanuary(Double.parseDouble(s0));
            }
            //entity.setFebruary(strings[7]);
            if (strings[7].equals("")) {
                entity.setFebruary(Double.valueOf(0));
            } else {
                entity.setFebruary(Double.parseDouble(strings[7]));
            }
            // entity.setMarch(strings[8]);
            if (strings[8].equals("")) {
                entity.setMarch(Double.valueOf(0));
            } else {
                entity.setMarch(Double.parseDouble(strings[8]));
            }
            // entity.setApril(strings[9]);
            if (strings[9].equals("")) {
                entity.setApril(Double.valueOf(0));
            } else {
                entity.setApril(Double.parseDouble(strings[9]));
            }
            //entity.setMay(strings[10]);
            if (strings[10].equals("")) {
                entity.setMay(Double.valueOf(0));
            } else {
                entity.setMay(Double.parseDouble(strings[10]));
            }
            // entity.setJune(strings[11]);
            if (strings[11].equals("")) {
                entity.setJune(Double.valueOf(0));
            } else {
                entity.setJune(Double.parseDouble(strings[11]));
            }
            //entity.setJuly(strings[12]);
            if (strings[12].equals("")) {
                entity.setJuly(Double.valueOf(0));
            } else {
                entity.setJuly(Double.parseDouble(strings[12]));
            }
            // entity.setAugust(strings[13]);
            if (strings[13].equals("")) {
                entity.setAugust(Double.valueOf(0));
            } else {
                entity.setAugust(Double.parseDouble(strings[13]));
            }
            //entity.setSeptember(strings[14]);
            if (strings[14].equals("")) {
                entity.setSeptember(Double.valueOf(0));
            } else {
                entity.setSeptember(Double.parseDouble(strings[14]));
            }
            // entity.setOctober(strings[15]);
            if (strings[15].equals("")) {
                entity.setOctober(Double.valueOf(0));
            } else {
                entity.setOctober(Double.parseDouble(strings[15]));
            }
            //entity.setNovember(strings[16]);
            if (strings[16].equals("")) {
                entity.setNovember(Double.valueOf(0));
            } else {
                entity.setNovember(Double.parseDouble(strings[16]));
            }
            //entity.setDecember(strings[17]);
            if (strings[17].equals("")) {
                entity.setDecember(Double.valueOf(0));
            } else {
                entity.setDecember(Double.parseDouble(strings[17]));
            }
            list.add(entity);
        }
        System.out.println(list);
        System.out.println("nihao");
        saveBatch(list);
    }
}
